<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>上传</title>
    <!-- Bootstrap -->
    <link rel="stylesheet" href="https://stackpath.bootstrapcdn.com/bootstrap/3.4.1/css/bootstrap.min.css" integrity="sha384-HSMxcRTRxnN+Bdg0JdbxYKrThecOKuH5zCYotlSAcp1+c8xmyTe9GYg1l9a69psu" crossorigin="anonymous">

</head>
<body>
    <div class="container">
        <form action="" enctype="multipart/form-data">
            <input class="" type="file" name="pic">
            <input class="btn" type="button" value="上传" @click="send()"><br>
            <img :src="url" alt="">
        </form>
    </div>
<!--引入axios框架-->
<script src="https://cdn.bootcdn.net/ajax/libs/axios/0.21.1/axios.min.js"></script>
<!--引入vue框架-->
<script src="https://cdn.jsdelivr.net/npm/vue@2/dist/vue.js"></script>
<script>
    let v = new Vue({
        el:"form",
        data:{
            url:""
        },
        methods:{
            send:function () {
                let data = new FormData(document.querySelector("form"));
                axios.post("/send",data).then(function (response) {
                    if (response.data != "err"){
                        alert("成功"+response.data);
                        v.url=response.data;
                    }else {
                        alert("失败");
                    }
                })
            }
        }
    })
</script>
</body>
</html>